<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑教师</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-4">
    <div class="row mb-3">
        <div class="col">
            <h1>编辑教师</h1>
        </div>
        <div class="col text-right">
            <a href="/teachers" class="btn btn-secondary">返回列表</a>
        </div>
    </div>

    <div class="card">
        <div class="card-body">
            <form th:action="@{/teachers/edit/{id}(id=${teacher.teacherId})}" method="post" th:object="${teacher}">
                <input type="hidden" th:field="*{teacherId}">
                
                <div class="form-group">
                    <label for="name">姓名</label>
                    <input type="text" class="form-control" id="name" th:field="*{name}" required>
                </div>
                
                <div class="form-group">
                    <label for="title">职称</label>
                    <input type="text" class="form-control" id="title" th:field="*{title}" required>
                </div>
                
                <div class="form-group">
                    <label for="email">邮箱</label>
                    <input type="email" class="form-control" id="email" th:field="*{email}" required>
                </div>
                
                <div class="form-group">
                    <label for="phone">电话</label>
                    <input type="tel" class="form-control" id="phone" th:field="*{phone}" required>
                </div>
                
                <div class="form-group">
                    <label for="department">所属部门</label>
                    <select class="form-control" id="department" name="department.deptId" required>
                        <option value="">请选择部门</option>
                        <option th:each="dept : ${departments}"
                                th:value="${dept.deptId}"
                                th:text="${dept.deptName}"
                                th:selected="${teacher.department != null && teacher.department.deptId == dept.deptId}">
                        </option>
                    </select>
                </div>
                
                <button type="submit" class="btn btn-primary">保存</button>
            </form>
        </div>
    </div>
</div>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html> 